package com.hanbang.taitaigou.ui.widget.autoloadding;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hanbang.taitaigou.R;
import com.hanbang.taitaigou.utils.ui.UiUtils;

/**
 * Created by Administrator on 2016/3/14.
 */
public class FooterView extends RelativeLayout {
    private ProgressBar progressBar;
    private TextView textView;
    private Context context;

    public FooterView(Context context) {
        this(context, null);
    }

    public FooterView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public FooterView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        UiUtils.getInflaterView(context, R.layout.autoloadding_footer, this);
        textView = (TextView) findViewById(R.id.tvLoadMore);
        progressBar = (ProgressBar) findViewById(R.id.progressbar);

        setEnabled(false);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        return true;
    }


    public void setStatus(LoadState status) {
        if (status == LoadState.Complete) {
            textView.setText(context.getString(R.string.autoloadding_no_data));
            progressBar.setVisibility(GONE);
            setVisibility(VISIBLE);
        } else if (status == LoadState.Loadding) {
            progressBar.setVisibility(VISIBLE);
            textView.setText(context.getString(R.string.autoloadding));
            setVisibility(VISIBLE);
        } else if (status == LoadState.None) {
            progressBar.setVisibility(GONE);
            textView.setText(context.getString(R.string.autoloadding_zhunbei));
            setVisibility(GONE);
        }
    }

}
